package grupb.upf.imageProcessing;

import java.awt.image.renderable.ParameterBlock;
import javax.media.jai.JAI;
import javax.media.jai.KernelJAI;
import javax.media.jai.PlanarImage;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Jesus
 */
public final class EdgeDetection {

    public PlanarImage execute(final PlanarImage img) {
        final float[] data =
        {-1.0f, -2.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 2.0f, 1.0f};
        final KernelJAI kernel = new KernelJAI(3, 3, data);
        final ParameterBlock pb = new ParameterBlock();
        pb.addSource(img);
        pb.add(kernel);
        final PlanarImage image = JAI.create("convolve", pb, null);
        return image;
    }
}
